<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
</head>

<body>
    <div id="app"></div>

    <template id="demo">
        <div>
            <h2>{{state.title}}</h2>
            <h3>{{state.count}}</h3>
            <button @click="decrement">-1</button>
            <button @click="add">+1</button>
        </div>
    </template>

    <script>
        const { reactive } = Vue
        const app = Vue.createApp({
            template: '#demo',
            setup() {
                let state = reactive({
                    title: 'Hello world',
                    count: 0
                })
                const decrement = () => {
                    state.count--
                }
                const add = () => {
                    state.count++
                }
                return {
                    state,
                    decrement,
                    add
                }
            },
        })
        app.mount('#app')
    </script>
</body>

</html>